package com.example.dell.zyfypt_225zxx.activity;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.example.dell.zyfypt_225zxx.R;
import com.example.dell.zyfypt_225zxx.iface.RegisterListener;
import com.example.dell.zyfypt_225zxx.model.RegisterModel;

public class RegisterActivity extends AppCompatActivity implements View.OnClickListener,RegisterListener{

    private EditText user,password,againpwd,name,tel;
    private Button register,returnlogin;
    private RegisterModel registerModel;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_register);
        init();
    }
    private void init(){
        user=(EditText)findViewById(R.id.editText_repass);//用户名
        password=(EditText)findViewById(R.id.editText_retel);//密码
        tel=(EditText)findViewById(R.id.editText_retel);//电话
        register=(Button)findViewById(R.id.button_reg);//注册
        returnlogin=(Button)findViewById(R.id.button_relogin);//返回登录

        returnlogin.setOnClickListener(this);
        register.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.button_reg:
                registerModel=new RegisterModel();
                registerModel.getResultList(user.getText().toString(),password.getText().toString(),tel.getText().toString(),this);
                break;
            case R.id.button_relogin://返回登陆界面
                Intent intent=new Intent(RegisterActivity.this,LoginActivity.class);
                startActivity(intent);
                break;
        }
    }

    @Override
    public void onResponse(String str) {
        Intent intent1=new Intent(RegisterActivity.this,LoginActivity.class);
        startActivity(intent1);
    }

    @Override
    public void onFail(String msg) {

    }
}
